<template>
  <uni-easyinput v-model="val" placeholder="输入" @confirm="confirmVal" @change="changeVal" @input="inputVal"></uni-easyinput>
  <uni-easyinput v-model="msg" placeholder="输入" type="textarea" @confirm="confirmText"></uni-easyinput>
  <button @click="print">log</button>
  <button @click="clearAll">clear</button>
</template>

<script setup>
  
  import { onMounted, ref } from "vue"
  import {onShow} from "@dcloudio/uni-app"
  
  const val = ref("")
  const msg =ref("")
  
  onShow(() => {
    msg.value = String.fromCharCode(10,10,49,10,50)
    val.value = String.fromCharCode(10,10,49,10,50)
    
    console.log(msg.value);
    console.log(val.value);
  })
  
  const print = () =>{
    console.log('00000000000000000000000000');
    console.log(val.value);
    console.log(val.value.length, val.value.trim().length);
    let t = val.value.trim()
    for(let i=0;i<t.length;i++) {
      console.log('----', i, t[i], t.charCodeAt(i));
    }
    console.log('000000000000000000000');
    
    
    // console.log(msg.value);
    // console.log(msg.value.length);
    // console.log(msg.value.trim(), msg.value.trim().length);
    // for(let i=0;i<msg.value.length;i++) {
    //   console.log(msg.value.charCodeAt(i));
    // }
    
  }
  
  const changeVal = (el) => {
    console.log('change', el, el.trim().length);
  }
  
  const inputVal = (el) => {
    console.log("input", el);
  }
  
  const confirmVal =(el) => {
    setTimeout(() => {
      console.log('单行');
      console.log(el);
      console.log(val.value);
    }, 1000)
  }
  
  const confirmText =(el) => {
    setTimeout(() => {
      console.log('多行');
      console.log(el);
      console.log(msg.value);
      console.log(msg.value.length);
      console.log(msg.value.trim());
    }, 1000)
  }
  
  const clearAll = () => {
    val.value = ""
    msg.value = ""
  }
  
</script>

<style>
</style>